var FormValidation = function () {
    return {
        init: function () {
            $('#entrustForm').validator({
                timely:2,
                theme:'yellow_top',
                rules: {
                    // 使用正则表达式定义规则
                    telephone: [/((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/, "请填写有效的联系电话"]
                },
                fields: {
                    'companyName': 'required',
                    'contactName': 'required',
                    'contactTel': 'required;telephone',
                    'budget': 'required;integer'
                },
                valid: function (form) {
                    $(form).ajaxSubmit(function (response) {
                        if (response.code == 200) {
                            layer.msgShort(response.message);
                            setTimeout(function() { window.location.reload(); }, 2000);
                        } else {
                            layer.msgShort(response.message);
                        }
                    });
                }
            });

        }

    };

}();

